<%--
    Document   : login
    Created on : Feb 23, 2011, 9:29:38 AM
    Author     : NGUYENVANHUNG
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Home Page</title>
    </head>
    <body>
        <%
        if(session.getAttribute("admin") == null){
            boolean login = false;
            Cookie[] cookies = request.getCookies();
            if (cookies != null){
                for (int i = 0; i < cookies.length; i++){
                    if (cookies [i].getName().equals ("loginRemember")){
                        login = true;
                        session.setAttribute("admin", cookies [i].getValue().split("###")[0]);
                        break;
                    }
                }
            }
            if(!login){
                response.sendRedirect("login.jsp");
            }
        }
        %>
        <form action="../adminLogoutServlet" method="post">
            <h1>Admin Home Page</h1>
            <input type="submit" value="Logout">
        </form>
    </body>
</html>
